home *** CD-ROM | disk | FTP | other *** search
- #include "my color.h"
-
-
- OpenWindow() /* Open a new window */
- {
- char wNameDef[256]; /* to hold our default window title */
- char nextWTitle[256]; /* title of next window to be opened*/
- char *wName;
-
- NumToString (nextWNum, nextWTitle); /* prepare number for title -- returns C string */
- PtoCstr(nextWTitle); /* convert to 'C' type string */
- strcpy((char *)wNameDef,WindName); /* WindName is a #define */
- wName = (char *)strcat((char *)wNameDef,(char *)nextWTitle);
- CtoPstr(wNameDef); /* convert to 'PASCAL' type string */
-
- myWindow = (CWindowPtr)NewCWindow (nil, &nextWRect, wNameDef, true, documentProc,
- (CWindowPtr)-1, true, 0);
- SetPort (myWindow); /*make it the current port*/
- add_scroll_bars(myWindow); /* create some scroll bars for the new window */
- set_color(myWindow); /* set the window's color to something hideous */
-
- txRect = thePort->portRect;
- txRect.right = txRect.right - BAR_WIDTH; /* make the text display rectangle allow for the scroll bars */
- txRect.bottom = txRect.bottom - BAR_WIDTH;
- InsetRect (&txRect, 4, 0);
- textH = TENew (&txRect, &txRect);
- myWinPeek = (CWindowPeek)myWindow;
- myWinPeek->refCon = (long)textH; /*keep TEHandle in the window's refCon field!*/
- OffsetRect (&nextWRect, windDX, windDY);/*move window down and right*/
- if (nextWRect.right > dragRect.right) /*move back if it's too far over*/
- OffsetRect (&nextWRect, -nextWRect.left + leftEdge, 0);
- if (nextWRect.bottom > dragRect.bottom)
- OffsetRect (&nextWRect, 0, -nextWRect.top + topEdge);
- nextWNum++; /*bump number for next window*/
- menusOK = false;
- EnableItem (myMenus [editM],0); /*in case this is the only window*/
- } /* OpenWindow */
-
-
- KillWindow(theWindow) /*Close a window and throw everything away*/
-
- CWindowPtr theWindow;
-
- {
- TEDispose (((CWindowPeek)theWindow)->refCon);
- /*throw away TERecord*/
- DisposeWindow (theWindow); /*throw away WindowRecord*/
- textH = nil; /*for TEIdle in main event loop*/
- if (FrontWindow() == nil) /*if no more windows, disable Close*/
- {
- DisableItem (myMenus[fileM], closeItem);
- SetCursor(&arrow);
- }
- else /* FrontWindow() != nil */
- {
- if (((CWindowPeek)FrontWindow())->windowKind < 0)
- /*if a desk acc is coming up, enable undo*/
- {
- EnableItem (myMenus[editM], undoItem);
- SetCursor(&arrow);
- }
- else
- DisableItem (myMenus[editM], undoItem);
- } /* else */
- } /*KillWindow*/
-
-